<?php
static $baseScriptUrl;
if (!isset($baseScriptUrl))
    $baseScriptUrl = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets')).'/gridview';
?>
<table class="items">
    <tr class="<?php echo $class;?>">
        <td><?php echo CHtml::link($model->title, array("update", "id"=>$model->id));?></td>
        <?php if (is_array($model->currentRevisions) && count($model->currentRevisions)):
            $sourceRevision = isset($model->currentRevisions[$sourceId]) ? $model->currentRevisions[$sourceId]->revision : 0;
            $targetRevision = isset($model->currentRevisions[$targetId]) ? $model->currentRevisions[$targetId]->revision : 0;
        ?>
        <td width="200" align="center">
            <?php echo $sourceRevision ? (($targetRevision && $targetRevision != $sourceRevision) ? CHtml::link('Rev#'.$sourceRevision, array('/Cms/admin/page/compareDetails', 'page_id'=>$model->currentRevisions[$sourceId]->page_id, 'source_revision'=>$sourceRevision, 'target_revision'=>$targetRevision, 'source_workflow_id'=>$sourceId, 'target_workflow_id'=>$targetId, 'layout'=>'popup'), array('class'=>'compare-details')) : 'Rev#'.$sourceRevision) : '';?>
            <?php echo ($sourceRevision && $targetRevision != $sourceRevision) ? CHtml::link(CHtml::image(Yii::app()->theme->baseUrl.'/images/copy_to_right.png', 'Copy to Right', array('align'=>'top')), array('/Core/service/ajax', 'SID'=>'Cms.pageRevision.activeWorkflow', 'page_id'=>$model->currentRevisions[$sourceId]->page_id, 'revision'=>$sourceRevision, 'workflow_id[]'=>$targetId), array('title'=>'Copy to Right', 'class'=>'sync_page')) : '';?>
        </td>
        <td width="200" align="center">
            <?php echo ($targetRevision && $targetRevision != $sourceRevision) ? CHtml::link(CHtml::image(Yii::app()->theme->baseUrl.'/images/copy_to_left.png', 'Copy to Left', array('align'=>'top')), array('/Core/service/ajax', 'SID'=>'Cms.pageRevision.activeWorkflow', 'page_id'=>$model->currentRevisions[$targetId]->page_id, 'revision'=>$targetRevision, 'workflow_id[]'=>$sourceId), array('title'=>'Copy to Left', 'class'=>'sync_page')) : '';?>
            <?php echo $targetRevision ? (($sourceRevision && $sourceRevision != $targetRevision) ? CHtml::link('Rev#'.$targetRevision, array('/Cms/admin/page/compareDetails', 'page_id'=>$model->currentRevisions[$targetId]->page_id, 'source_revision'=>$sourceRevision, 'target_revision'=>$targetRevision, 'source_workflow_id'=>$sourceId, 'target_workflow_id'=>$targetId, 'layout'=>'popup'), array('class'=>'compare-details')) : 'Rev#'.$targetRevision) : '';?>            
        </td>
        <?php else:?>
        <td width="200"></td>
        <td width="200"></td>
        <?php endif;?>
    </tr>
</table>